#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2023/8/16 21:44
# @Author  : BadMan
# @FileName: 01.字典操作.py

my_dict = {"周佳琪":80,
           "阿峰":90,
           "叶小儿":60}

for key in my_dict:
    print(f"my_dict的key是：{key}")
    print(f"my_dict的value是:{my_dict[key]}")

# 计算字典元素数量 len()
res = len(my_dict)
print(res)

# 练习
# 定义字典
info_dict = {
    "王力宏":{
        "部门":"科技部",
        "工资":3000,
        "级别":1
    },
    "周杰伦":{
        "部门":"市场部",
        "工资":5000,
        "级别":2
    },
    "林俊杰":{
        "部门":"市场部",
        "工资":7000,
        "级别":3
    },
    "张学友":{
        "部门":"科技部",
        "工资":4000,
        "级别":1
    },
    "刘德华":{
        "部门":"市场部",
        "工资":6000,
        "级别":2
    }
}
print(f"员工信息如下:{info_dict}")

# 通过 for 循环，对所有级别为 1 级的员工，级别上升1，薪资增加1000
for key in info_dict:
    if info_dict[key]["级别"] == 1:
       # 升职加薪操作
       # 获取员工信息
       employee_info_dict = info_dict[key]
       # 修改员工信息
       employee_info_dict["级别"] == 2  # 级别+1
       employee_info_dict["工资"] == employee_info_dict["工资"] + 1000
       # 将员工的信息更新回 info_dict
       info_dict[key] = employee_info_dict
print(f"更新后的信息为:{info_dict}")

